package com.flowcloud.kafka.config;

import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import org.apache.kafka.clients.admin.NewTopic;
import org.springframework.boot.context.properties.ConfigurationProperties;

import java.util.List;

/**
 * @program: uip
 * @description: topic配置类
 * @author: wuwenbin
 * @create: 2020-12-18 02:11
 */
@ConfigurationProperties(prefix = "spring.kafka")
@Setter
@Getter
@ToString
class TopicConfigurations {
	private List<Topic> topics;

	@Setter
	@Getter
	@ToString
	static class Topic {
		String name;
		Integer numPartitions = 2;
		Short replicationFactor = 1;

		NewTopic toNewTopic() {
			return new NewTopic(this.name, this.numPartitions, this.replicationFactor);
		}
	}
}
